﻿@model PagedList.IPagedList<Dziennik_MVC.Models.Entities.Prowadzacy>

@{
    ViewBag.Title = "Lista prowadzących";
    Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
}

<div class="pageTitle">
    <h2>Akutalna lista prowadzących</h2>
</div>

<div class="opcje">
    @Html.ActionLink("Dodaj prowadzącego", "Add")
</div>

<table>
    <tr>      
        <th>
            @Html.ActionLink("Imię", "List", new { sortOrder = ViewBag.NameSortParm })

            @if (ViewBag.CurrentSort == "Name asc")
            {
             @:<div class="sorting">
              @:↑
             @:</div>
            }
            @if (ViewBag.CurrentSort == "Name desc")
            { 
              @:<div class="sorting">
              @:↓
              @:</div>
            }            
        </th>       
        <th>
            @Html.ActionLink("Nazwisko", "List", new { sortOrder = ViewBag.LastNameSortParm })

            @if (ViewBag.CurrentSort == "LastName asc")
            {
             @:<div class="sorting">
              @:↑
             @:</div>
            }
            @if (ViewBag.CurrentSort == "LastName desc")
            { 
              @:<div class="sorting">
              @:↓
              @:</div>
            }            
        </th>        
        <th style="width:20px;">
            @Html.ActionLink("Administrator", "List", new { sortOrder = ViewBag.GroupParm })

            @if (ViewBag.CurrentSort == "Admin asc")
            {
             @:<div class="sorting">
              @:↑
             @:</div>
            }
            @if (ViewBag.CurrentSort == "Admin desc")
            { 
              @:<div class="sorting">
              @:↓
              @:</div>
            }            
        </th>      
        <th></th>
    </tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.imie)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.nazwisko)
        </td>    
        <td style="width:20px;">
            @Html.CheckBoxFor(modelItem => item.admin, new { disabled = "disabled", style = "display:inherit" })
        </td>       
        <td>
            @Html.ActionLink("Przypisz przedmioty", "PrzypiszPrzedmioty", new { id = item.id_prowadzacego }) |
            @Html.ActionLink("Edytuj", "Edit", new { id = item.id_prowadzacego }) |
            @Html.ActionLink("Usuń", "Delete", new { id = item.id_prowadzacego })
        </td>
    </tr>
}

</table>

<div>
    Strona @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber)
    z @Model.PageCount
     
    @if (Model.HasPreviousPage)
    {
        @Html.ActionLink("<<", "List", new { page = 1, sortOrder = ViewBag.CurrentSort })
        @Html.Raw(" ");
        @Html.ActionLink("< Poprzednia", "List", new { page = Model.PageNumber - 1, sortOrder = ViewBag.CurrentSort })
    }
    else
    {
        @:<<
        @Html.Raw(" ");
        @:< Poprzednia
    }
     
    @if (Model.HasNextPage)
    {
        @Html.ActionLink("Następna >", "List", new { page = Model.PageNumber + 1, sortOrder = ViewBag.CurrentSort })
        @Html.Raw(" ");
        @Html.ActionLink(">>", "List", new { page = Model.PageCount, sortOrder = ViewBag.CurrentSort })
    }
    else
    {
        @:Następna >
        @Html.Raw(" ")
        @:>>
    }
</div>
